﻿@page "/posts/list"
@inherits PageBase

<PageContainer>
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem><Icon Type="home"></Icon></BreadcrumbItem>
            <BreadcrumbItem><Icon Type="read"></Icon><span>文章管理</span></BreadcrumbItem>
            <BreadcrumbItem><Icon Type="bars"></Icon><span>文章列表</span></BreadcrumbItem>
        </Breadcrumb>
    </Breadcrumb>
    <ChildContent>
        <Card>
            <Table TItem="GetAdminPostDto"
                   DataSource="@posts"
                   Bordered=@true
                   Size=@TableSize.Small
                   Total="total"
                   @bind-PageIndex="page"
                   @bind-PageSize="limit"
                   OnPageIndexChange="HandlePageIndexChange">
                <Column @bind-Field="@context.Id" Title="Id" Sortable="false"></Column>
                <Column @bind-Field="@context.Title" Title="标题" Sortable="false">
                    @context.Title
                </Column>
                <Column @bind-Field="@context.Category" Title="分类" Sortable="false">
                    @context.Category.Name
                </Column>
                <Column @bind-Field="@context.Tags" Title="标签" Sortable="false">
                    @foreach (var tag in context.Tags)
                    {
                        <Tag Color="blue">@tag.Name</Tag>
                    }
                </Column>
                <Column @bind-Field="@context.CreatedAt" Title="创建时间" Sortable="false"></Column>
                <ActionColumn Title="操作">
                    <Space Size="@("small")">
                        <SpaceItem>
                            <Button Type="@ButtonType.Primary" OnClick="(() => Goto(context.Id))">编辑</Button>
                        </SpaceItem>
                        <SpaceItem>
                            <Popconfirm Title="确定删除吗?"
                                        Icon="close-circle"
                                        OnConfirm="(async () => await DeleteAsync(context.Id))">
                                <Button Danger>删除</Button>
                            </Popconfirm>
                        </SpaceItem>
                    </Space>
                </ActionColumn>
            </Table>
        </Card>
    </ChildContent>
</PageContainer>